package com.ag.wsq.action;

import java.util.Date;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.struts2.interceptor.SessionAware;

import com.ag.bean.TbConnectLog;
import com.ag.bean.TbConnectLogId;
import com.ag.common.BaseAction;
import com.ag.common.PageUtil;
import com.ag.common.PermissionServiceImpl;
import com.ag.wsq.service.impl.ConnectLogServiceImpl;
/*
 * @author 王淑其
 */
public class WatchLogAction extends BaseAction implements SessionAware{

	
	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(WatchLogAction.class);
	private ConnectLogServiceImpl connectLogServiceImpl;
	private PermissionServiceImpl pms;
	private String UId;
	private String UName;
	private String timeStart;
	private String timeEnd;
	private PageUtil  pageUtil;
	private int total;
	private int page;
	private int maxRow;
	private Map<String, Object> sessionMap;
	/*
	 * 提供Map<String, Object>类型的Session变量，用来保存Struts2注入的Session上下文
	 */
	
	@Override
	public void setSession(Map<String, Object> session) {
		this.setSessionMap(session);
	}
	/*
	 * 保存交接班日志,在session中取得用户的UId
	 * 
	 */
	public String recordLog(){
		TbConnectLog cLog = new TbConnectLog();
		TbConnectLogId cLogId = new TbConnectLogId();
		cLogId.setUId(pms.getCurrentUser(sessionMap).getUId());
		cLogId.setStartTime(new Date());
		cLog.setId(cLogId);
		
		connectLogServiceImpl.recordLog(cLog);
		
		return "recordOK";
	}
	/*
	 * 查询交接班日志
	 * 
	 */
	public String findLog(){
		logger.info("satrt findWatchLog---------");
		pageUtil = connectLogServiceImpl.WatchLog(total, page, maxRow, UId, UName, timeStart, timeEnd);
		logger.info("return pageUtil--------"+pageUtil);
		return "findWatchOK";
	}
	
	public ConnectLogServiceImpl getConnectLogServiceImpl() {
		return connectLogServiceImpl;
	}
	public void setConnectLogServiceImpl(ConnectLogServiceImpl connectLogServiceImpl) {
		this.connectLogServiceImpl = connectLogServiceImpl;
	}
	public String getUId() {
		return UId;
	}
	public void setUId(String uId) {
		UId = uId;
	}

	public String getUName() {
		return UName;
	}

	public void setUName(String uName) {
		UName = uName;
	}

	public String getTimeStart() {
		return timeStart;
	}

	public void setTimeStart(String timeStart) {
		this.timeStart = timeStart;
	}

	public String getTimeEnd() {
		return timeEnd;
	}

	public void setTimeEnd(String timeEnd) {
		this.timeEnd = timeEnd;
	}

	public PageUtil getPageUtil() {
		return pageUtil;
	}

	public void setPageUtil(PageUtil pageUtil) {
		this.pageUtil = pageUtil;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getMaxRow() {
		return maxRow;
	}

	public void setMaxRow(int maxRow) {
		this.maxRow = maxRow;
	}
	public void setSessionMap(Map<String, Object> sessionMap) {
		this.sessionMap = sessionMap;
	}
	public Map<String, Object> getSessionMap() {
		return sessionMap;
	}
	public PermissionServiceImpl getPms() {
		return pms;
	}
	public void setPms(PermissionServiceImpl pms) {
		this.pms = pms;
	}
	
}
